package com.xayy.mgt.controller;

import cn.kawins.base.result.ResultBody;
import cn.kawins.mybatis.base.BaseController;
import cn.kawins.spring.mvc.validator.Group;
import com.github.pagehelper.PageInfo;
import com.xayy.mgt.model.PerformanceIndicators;
import com.xayy.mgt.model.dto.NodeInfoDto;
import com.xayy.mgt.model.vo.PerformanceIndicatorVo;
import com.xayy.mgt.service.PerformanceIndicatorsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/xnzbx1")
@Api(tags = "性能指标项")
public class PerformanceIndicatorsController extends BaseController<PerformanceIndicators> {

    @Autowired
    private PerformanceIndicatorsService performanceIndicatorsService;

    @PostMapping("/savePerformanceIndicators")
    @ApiOperation(value = "新增功能指标项")
    public ResultBody savePerformanceIndicators(@Validated(Group.Insert.class) @RequestBody PerformanceIndicatorVo performanceIndicatorVo) {
        return performanceIndicatorsService.savePerformanceIndicators(performanceIndicatorVo).body();
    }

    @PutMapping("/updatePerformanceIndicators")
    @ApiOperation(value = "修改功能指标项")
    public ResultBody updatePerformanceIndicators(@RequestBody PerformanceIndicatorVo performanceIndicatorVo) {
        return performanceIndicatorsService.updatePerformanceIndicators(performanceIndicatorVo).body();
    }

    @GetMapping("/getInfo/{id}")
    @ApiOperation(value = "查看性能指标详情", response = PerformanceIndicatorVo.class)
    public ResultBody getInfo(@PathVariable Long id) {
        return performanceIndicatorsService.getInfo(id).body();
    }

    @DeleteMapping("/deletePerformanceIndicators/{id}")
    @ApiOperation(value = "删除性能指标信息")
    public ResultBody deletePerformanceIndicators(@PathVariable Long id) {
        return performanceIndicatorsService.deletePerformanceIndicators(id).body();
    }

    @PostMapping("/pageList")
    @ApiOperation(value = "性能指标（分页）")
    public ResultBody performanceIndicatorsPageList(@RequestBody NodeInfoDto nodeInfoDto) {
        PageInfo<PerformanceIndicators> page = performanceIndicatorsService.pageList(nodeInfoDto);
        return ResultBody.success(page);
    }

}
